//
//  237_删除链表中的节点.swift
//  Swift-LeetCode
//
//  Created by 卢悦明 on 2024/1/18.
//

import UIKit

class DeleteNode: NSObject {
    static func QA() {
        
        var link = LinkedList<Int>();
        let head = link.creatList(array: [0, 1, 2, 3, 4, 5])
        LinkedList.printList(head)
        let node = link.nodeOfIndex(2);
        let delete = DeleteNode()
        delete.deleteNode(node)
        
        link.printList()
        
    }
    // 237.删除链表中的节点
    func deleteNode(_ node: ListNode<Int>?) {
        node?.val = node?.next?.val ?? 0
        node?.next = node?.next?.next
    }
}
